package com.wd.tw.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wd.tw.domain.entity.ElevatorRunTime;
import com.wd.tw.service.ElevatorRunTimeService;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wd.common.core.controller.BaseController;
import com.wd.common.core.domain.HttpResponse;
import com.wd.common.annotation.Log;
import com.wd.common.enums.BusinessType;

import com.wd.common.utils.poi.ExcelUtil;


/**
 * 电梯运行时长Controller
 * 
 * @author liumingkun
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/business/time")
public class ElevatorRunTimeController extends BaseController
{
    @Resource
    private ElevatorRunTimeService elevatorRunTimeService;

    /**
     * 查询电梯运行时长列表
     */
    @PreAuthorize("@ss.hasPermi('business:time:list')")
    @GetMapping("/list")
    public HttpResponse list(ElevatorRunTime elevatorRunTime)
    {
        startPage();
        List<ElevatorRunTime> list = elevatorRunTimeService.selectElevatorRunTimeList(elevatorRunTime);
        return HttpResponse.successData(getDataTable(list));
    }

    /**
     * 导出电梯运行时长列表
     */
    @PreAuthorize("@ss.hasPermi('business:time:export')")
    @Log(title = "电梯运行时长", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElevatorRunTime elevatorRunTime)
    {
        List<ElevatorRunTime> list = elevatorRunTimeService.selectElevatorRunTimeList(elevatorRunTime);
        ExcelUtil<ElevatorRunTime> util = new ExcelUtil<ElevatorRunTime>(ElevatorRunTime.class);
        util.exportExcel(response, list, "电梯运行时长数据");
    }

    /**
     * 获取电梯运行时长详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:time:query')")
    @GetMapping(value = "/{recordId}")
    public HttpResponse getInfo(@PathVariable("recordId") Long recordId)
    {
        return successData(elevatorRunTimeService.selectElevatorRunTimeByRecordId(recordId));
    }

    /**
     * 新增电梯运行时长
     */
    @PreAuthorize("@ss.hasPermi('business:time:add')")
    @Log(title = "电梯运行时长", businessType = BusinessType.INSERT)
    @PostMapping
    public HttpResponse add(@RequestBody ElevatorRunTime elevatorRunTime)
    {
        return getResult(elevatorRunTimeService.insertElevatorRunTime(elevatorRunTime));
    }

    /**
     * 修改电梯运行时长
     */
    @PreAuthorize("@ss.hasPermi('business:time:edit')")
    @Log(title = "电梯运行时长", businessType = BusinessType.UPDATE)
    @PutMapping
    public HttpResponse edit(@RequestBody ElevatorRunTime elevatorRunTime)
    {
        return getResult(elevatorRunTimeService.updateElevatorRunTime(elevatorRunTime));
    }

    /**
     * 删除电梯运行时长
     */
    @PreAuthorize("@ss.hasPermi('business:time:remove')")
    @Log(title = "电梯运行时长", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public HttpResponse remove(@PathVariable Long[] recordIds)
    {
        return getResult(elevatorRunTimeService.deleteElevatorRunTimeByRecordIds(recordIds));
    }
}
